<?php
$host="db.seng.uvic.ca"; // Host name
$username="se321g01"; // Mysql username
$password="un8bi2YM"; // Mysql password
$db_name="se321g01"; // Database name
$tbl_name="user_info"; // Table name

// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

$sql="SELECT * FROM ads_info";
$result=mysql_query($sql);
$i = 0;
while($row = mysql_fetch_array($result))
{
	$linktext = 'link' .$i;
	$del = 'del' .$i;
	$thefile = $row['file'];
	$thelink = $_POST[$linktext];
	if(isset($_POST[$del])) 
	{
		mysql_query("DELETE from ads_info where file='$thefile'");
		unlink('/home/se321g01/.www/prototype/admin/uploads/'.basename($thefile));
	} else
	{
		mysql_query("UPDATE ads_info SET link='$thelink' WHERE file='$thefile'");
	}
	$i++;
}

$uid = $_GET['uid'];
header("location:./profile.php?uid=" . $uid . "&tab=4");
?>